package com.ymatou.iapi.m.couponservice.testcase;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.m.couponservice.parameter.GetSellerBatchesByPagingBean;
import com.ymatou.iapi.m.couponservice.parameter.SellerCreateBatchBean;
import com.ymatou.iapi.m.couponservice.parameter.batchinfo3;
import com.ymatou.iapi.m.couponservice.service.GetSellerBatchesByPagingCall;
import com.ymatou.iapi.m.couponservice.service.SellerCreateBatchCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponServiceMCallService;
import com.ymttest.database.sqlwapper.YmtCouponBatchWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
/**
*分页获取商家优惠券批次信息
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetSellerBatchesByPaging{
	private static GetSellerBatchesByPagingBean getsellerbatchesbypagingBean;
	private static GetSellerBatchesByPagingCall getsellerbatchesbypagingCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分页获取商家优惠券批次信息");
	}

	@Before
	public void caseUp() {
		getsellerbatchesbypagingBean=new GetSellerBatchesByPagingBean();
		getsellerbatchesbypagingCall=new GetSellerBatchesByPagingCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getsellerbatchesbypagingCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_001() {
		Logger.start(true,"根据商家获取批次列表信息");
		try {
			
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(-1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        	 
		        	 Map item = new YmtCouponBatchWapper().selectBatchInfoBysBatchCode(batchCode).get(0);
		        	
		        	Logger.verifyEquals(sellerId, Integer.parseInt(item.get("iOperatorId").toString()), "验证iOperatorId");
		        			        
		        }	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_002() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息");
		try {
			Map batch = new YmtCouponBatchWapper().getTop1SellerCouponInfo().get(0);
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("iOperatorId").toString()));
			getsellerbatchesbypagingBean.setBatchCode(batch.get("sBatchCode").toString());
			getsellerbatchesbypagingBean.setBatchStatus(-1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        
		        	Logger.verifyEquals(getsellerbatchesbypagingBean.getBatchCode(), batchInfo.getBatchCode(), "验证BatchCode");
		        			        
		        }		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_003() {
		Logger.start(true,"根据优惠券批次名称获取优惠券批次列表信息");
		try {
			Map batch = new YmtCouponBatchWapper().getTop1SellerCouponInfo().get(0);
			
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("iOperatorId").toString()));			
			getsellerbatchesbypagingBean.setBatchName(batch.get("sCouponName").toString());
			getsellerbatchesbypagingBean.setBatchStatus(-1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        
		        	Logger.verifyEquals(true, batchInfo.getBatchName().contains(getsellerbatchesbypagingBean.getBatchName()), "验证batchName");
		        			        
		        }	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_004() {
		Logger.start(true,"根据有效期获取商家优惠券批次列表信息");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(-1);
			
			 Date dNow = new Date(); // 当前时间
		        Date dBefore = new Date();
		        Date dAfter = new Date();

		        Calendar calendar1 = Calendar.getInstance(); // 得到日历
		        calendar1.setTime(dNow);// 把当前时间赋给日历
		        calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
		        dBefore = calendar1.getTime(); // 得到前一天的时间

		        Calendar calendar2 = Calendar.getInstance(); // 得到日历
		        calendar2.setTime(dNow);// 把当前时间赋给日历
		        calendar2.add(Calendar.DAY_OF_MONTH, 10); // 设置为后十天
		        dAfter = calendar2.getTime(); // 得到前一天的时间
		        
		        getsellerbatchesbypagingBean.setEffectiveStartTime(dBefore);
		        getsellerbatchesbypagingBean.setEffectiveEndTime(dAfter);
		        
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();			
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        	 
		        	 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		        	 
		        	 Date startTime=sdf.parse(sdf.format(YMTDateUtil.getDateFromReturn(batchInfo.getEffectiveStartTime())));
		        	 Date endTime=sdf.parse(sdf.format(YMTDateUtil.getDateFromReturn(batchInfo.getEffectiveEndTime())));
				        
		        	 Date d1=sdf.parse(sdf.format(dBefore)); 
		        	 Date d2=sdf.parse(sdf.format(dAfter));
		        	 

		        	 Logger.comment("传入时间区间：");
		        	 Logger.comment(sdf.format(d1));
		        	 Logger.comment(sdf.format(d2));
		        	 
		        	 Logger.comment("返回时间区间：");
		        	 Logger.comment(sdf.format(startTime));
		        	 Logger.comment(sdf.format(endTime));
		        	 
		        	Logger.verifyEquals(false, startTime.after(d2)||endTime.before(d1), "验证effectiveStartTime");
			        		        
		        }	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_005() {
		Logger.start(true,"根据优惠券批次状态-领取中 获取优惠券批次列表信息");
		try {
			Map batch = new YmtCouponBatchWapper().getTop1SellerCouponInfo().get(0);
			
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("iOperatorId").toString()));			
			getsellerbatchesbypagingBean.setBatchStatus(0);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        
		        	Logger.verifyEquals(0, batchInfo.getBatchStatus(), "验证batchName");
		        	
		        	Map item = new YmtCouponBatchWapper().selectBatchInfoBysBatchCode(batchCode).get(0);
		        	 
		        	 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		        	 
		        	 Date time=sdf.parse(item.get("dValidEnd").toString());		       
		        	 
		        	 Logger.verifyEquals(true, time.after(new Date()), "验证s.dValidEnd > getdate()");
					    
		        	 Logger.verifyEquals(true, Integer.parseInt(item.get("iCouponTotalNum").toString())>Integer.parseInt(item.get("iReceiveCount").toString()), "验证b.iCouponTotalNum <= s.iReceiveCount");
		        	 
		        	 if(item.get("bInvalidStatus")!=null)
		        	 {
		        		 Logger.verifyEquals(false, Boolean.parseBoolean(item.get("bInvalidStatus").toString()), "验证bInvalidStatus)");
		        	 }        
		        }	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_006() {
		Logger.start(true,"根据优惠券批次状态-停止发放 获取优惠券批次列表信息");
		try {
			Map batch = new YmtCouponBatchWapper().getTop1SellerCouponInfo().get(0);
			
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("iOperatorId").toString()));			
			getsellerbatchesbypagingBean.setBatchStatus(1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(batchList.size(), Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount()), "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        
		        	 Logger.verifyEquals(1, batchInfo.getBatchStatus(), "验证batchName");
		        	
		        	 Map item = new YmtCouponBatchWapper().selectBatchInfoBysBatchCode(batchCode).get(0);
		        	 
		        	 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		        	 
		        	 Date time=sdf.parse(item.get("dValidEnd").toString());		       
		        	 
		        	 Logger.verifyEquals(true, time.after(new Date()), "验证s.dValidEnd > getdate()");
					    
		        	 if(item.get("bInvalidStatus")!=null)
		        	 {
		        		 Logger.verifyEquals(true, Boolean.parseBoolean(item.get("bInvalidStatus").toString()), "验证bInvalidStatus)");
		        	 }
		        }	
		        
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_007() {
		Logger.start(true,"根据优惠券批次状态-过期 获取优惠券批次列表信息");
		try {
			Map batch = new YmtCouponBatchWapper().getTop1SellerCouponInfo().get(0);
			
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("iOperatorId").toString()));			
			getsellerbatchesbypagingBean.setBatchStatus(2);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(batchList.size(), Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount()), "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        
		        	Logger.verifyEquals(2, batchInfo.getBatchStatus(), "验证batchName");
		        	
		        	Map item = new YmtCouponBatchWapper().selectBatchInfoBysBatchCode(batchCode).get(0);
		        	 
		        	 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		        	 
		        	 Date time=sdf.parse(item.get("dValidEnd").toString());		       
		        	 
		        	 Logger.verifyEquals(false, time.after(new Date()), "验证s.dValidEnd <= getdate()");
	        
		        }	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_008() {
		Logger.start(true,"根据优惠券批次状态-已领完 获取优惠券批次列表信息");
		try {
			Map batch = new YmtCouponBatchWapper().getTop1SellerCouponInfo().get(0);
			
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("iOperatorId").toString()));			
			getsellerbatchesbypagingBean.setBatchStatus(3);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(batchList.size(), Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount()), "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        
		        	 Logger.verifyEquals(3, batchInfo.getBatchStatus(), "验证batchName");
		        	
		        	 Map item = new YmtCouponBatchWapper().selectBatchInfoBysBatchCode(batchCode).get(0);
		        	 
		        	 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		        	 
		        	 Date time=sdf.parse(item.get("dValidEnd").toString());		       
		        	 
		        	 Logger.verifyEquals(true, time.after(new Date()), "验证s.dValidEnd > getdate()");
					    
		        	 Logger.verifyEquals(true, Integer.parseInt(item.get("iCouponTotalNum").toString())<=Integer.parseInt(item.get("iReceiveCount").toString()), "验证b.iCouponTotalNum <= s.iReceiveCount");
		        	 
		        	 if(item.get("bInvalidStatus")!=null)
		        	 {
		        		 Logger.verifyEquals(false, Boolean.parseBoolean(item.get("bInvalidStatus").toString()), "验证bInvalidStatus)");
		        	 }
					        	        
		        }	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_009() {
		Logger.start(true,"根据商家与coupontype获取批次列表信息-0：不限");
		try {
			// 普通券
			CouponServiceMCallService couponServiceMCallService = new CouponServiceMCallService();
			SellerCreateBatchBean sellercreatebatchBean = couponServiceMCallService.setDefaultSellerCreateBatchBean();
			
			SellerCreateBatchCall sellerCreateBatchCall1 = couponServiceMCallService.SellerCreateBatch(sellercreatebatchBean);

			// 分享券	
			sellercreatebatchBean.setCouponType((byte)2);
			sellercreatebatchBean.setEffectiveDays(2);
		
			SellerCreateBatchCall sellerCreateBatchCall2 = couponServiceMCallService.SellerCreateBatch(sellercreatebatchBean);
			
			getsellerbatchesbypagingBean.setSellerId(sellercreatebatchBean.getSellerId());
			getsellerbatchesbypagingBean.setBatchStatus(-1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			getsellerbatchesbypagingBean.setCouponType((byte)0);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(2, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount()), "验证返回优惠券数量");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        	 
		        	 Map item = new YmtCouponBatchWapper().selectBatchInfoBysBatchCode(batchCode).get(0);
		        	
		        	Logger.verifyEquals(sellercreatebatchBean.getSellerId(), Integer.parseInt(item.get("iOperatorId").toString()), "验证iOperatorId");
		        			        
		        }	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_010() {
		Logger.start(true,"根据商家与coupontype获取批次列表信息- 1：普通券");
		try {
			// 普通券
			CouponServiceMCallService couponServiceMCallService = new CouponServiceMCallService();
			SellerCreateBatchBean sellercreatebatchBean = couponServiceMCallService.setDefaultSellerCreateBatchBean();
			
			SellerCreateBatchCall sellerCreateBatchCall1 = couponServiceMCallService.SellerCreateBatch(sellercreatebatchBean);

			// 分享券	
			sellercreatebatchBean.setCouponType((byte)2);
			sellercreatebatchBean.setEffectiveDays(2);
		
			SellerCreateBatchCall sellerCreateBatchCall2 = couponServiceMCallService.SellerCreateBatch(sellercreatebatchBean);
			
			getsellerbatchesbypagingBean.setSellerId(sellercreatebatchBean.getSellerId());
			getsellerbatchesbypagingBean.setBatchStatus(-1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			getsellerbatchesbypagingBean.setCouponType((byte)1);

			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(1, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount()), "验证返回优惠券数量");
			Logger.verifyEquals(sellerCreateBatchCall1.getBatchCode(), getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos().get(0).getBatchCode(), "验证只返回普通券");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_011() {
		Logger.start(true,"根据商家与coupontype获取批次列表信息- 1：分享券");
		try {
			// 普通券
			CouponServiceMCallService couponServiceMCallService = new CouponServiceMCallService();
			SellerCreateBatchBean sellercreatebatchBean = couponServiceMCallService.setDefaultSellerCreateBatchBean();
			
			SellerCreateBatchCall sellerCreateBatchCall1 = couponServiceMCallService.SellerCreateBatch(sellercreatebatchBean);

			// 分享券	
			sellercreatebatchBean.setCouponType((byte)2);
			sellercreatebatchBean.setEffectiveDays(2);
		
			SellerCreateBatchCall sellerCreateBatchCall2 = couponServiceMCallService.SellerCreateBatch(sellercreatebatchBean);
			
			getsellerbatchesbypagingBean.setSellerId(sellercreatebatchBean.getSellerId());
			getsellerbatchesbypagingBean.setBatchStatus(-1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			getsellerbatchesbypagingBean.setCouponType((byte)2);

			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(1, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount()), "验证返回优惠券数量");
			Logger.verifyEquals(sellerCreateBatchCall2.getBatchCode(), getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos().get(0).getBatchCode(), "验证只返回普通券");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private void verifyReturn()
	{
			 List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
	        
	        for(int i=0;i<batchList.size();i++)
	        {
	        	 String batchCode = batchList.get(i).getBatchCode();
	        	 batchinfo3 batchInfo = batchList.get(i);
	        	 
	        	 Map item = new YmtCouponBatchWapper().selectBatchInfoBysBatchCode(batchCode).get(0);

	             Logger.verifyEquals(Integer.parseInt(item.get("iBatchId").toString()),
	             		batchInfo.getBatchId(),
	                     "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                             + "记录中iBatchId字段相同");
	             
	             Logger.verifyEquals(item.get("sBatchCode").toString(),
	             		batchInfo.getBatchCode(),
	                     "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                             + "记录中sBatchCode字段相同");

	             Logger.verifyEquals(item.get("sCouponName").toString(),
		             		batchInfo.getBatchName(),
		                     "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
		                             + "记录中sCouponName字段相同");
	          
	             Logger.verifyEquals(item.get("dValidStart").toString().subSequence(0, 19),
	             		batchInfo.getEffectiveStartTime().replace("T", " "),
	                     "验证返回dValidStart与数据库中表Ymt_CouponSetting中dValidStart字段相同");

	             Logger.verifyEquals(item.get("dValidEnd").toString().subSequence(0, 19),
	             		batchInfo.getEffectiveEndTime().replace("T", " "),
	                     "验证返回dValidEnd与数据库中表Ymt_CouponSetting中dValidEnd字段相同");
	             
	             Logger.verifyEquals(Boolean.parseBoolean(item.get("IsShowInPage").toString()),
		             		batchInfo.isShowInPage(),
		                     "验证返回isShowInPage与数据库中表Ymt_CouponBatch中isShowInPage字段相同");
		           
	             Logger.verifyEquals(Boolean.parseBoolean(item.get("bInvalidStatus").toString()),
		             		batchInfo.isInvalid(),
		                     "验证返回bInvalidStatus与数据库中表Ymt_CouponBatch中bInvalidStatus字段相同");
	             
	             Logger.verifyEquals(Integer.parseInt(item.get("iCouponTotalNum").toString()),
		             		batchInfo.getCouponTotalNum(),
		                     "验证返回CouponTotalNum与数据库中表Ymt_CouponBatch中CouponTotalNum字段相同");
	             
	             Logger.verifyEquals(Integer.parseInt(item.get("iReceiveCount").toString()),
		             		batchInfo.getReceivedCount(),
		                     "验证返回ReceivedCount与数据库中表Ymt_CouponSetting中ReceivedCount字段相同");
		
	             Logger.verifyEquals(Byte.parseByte(item.get("CouponType").toString()),
		             		batchInfo.getCouponType(),
		                     "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
		                             + "记录中coupontype字段相同");
	      
	        }
	}
}